<?php
/**
 * Author:   tangxiaowen
 * Email:    846506584@qq.com
 * Date:     2019/5/23 0023
 * Describe: 银行管理类.
 */

namespace app\api\controller\lishidai;

class Bank extends Base
{
    //银行卡数据 (立时贷提供)
    private $bankData = [
        ['bank_name' => '工商银行', 'bank_code' => 'ICBC', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '农业银行', 'bank_code' => 'ABC', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '中国银行', 'bank_code' => 'BOC', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '建设银行', 'bank_code' => 'CCB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '交通银行', 'bank_code' => 'BCOM', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '民生银行', 'bank_code' => 'CMBC', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '招商银行', 'bank_code' => 'CMB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '邮储银行', 'bank_code' => 'POST', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '平安银行', 'bank_code' => 'PAB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '中信银行', 'bank_code' => 'CITIC', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '光大银行', 'bank_code' => 'CEB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '兴业银行', 'bank_code' => 'CIB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '广发银行', 'bank_code' => 'GDB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '华夏银行', 'bank_code' => 'HXB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '南京银行', 'bank_code' => 'NJCB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '浦发银行', 'bank_code' => 'SPDB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '北京银行', 'bank_code' => 'BOB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '杭州银行', 'bank_code' => 'HZB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '宁波银行', 'bank_code' => 'NBCB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '浙商银行', 'bank_code' => 'CZB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '徽商银行', 'bank_code' => 'HSB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '渤海银行', 'bank_code' => 'CBHB', 'bank_title' => '', 'bank_icon' => ''],
        ['bank_name' => '汉口银行', 'bank_code' => 'HKBANK', 'bank_title' => '', 'bank_icon' => ''],
    ];

    /**
     * 获取银行卡列表.
     */
    public function getValidBankList()
    {
        successResult($this->bankData);
    }

    /**
     * 根据银行卡code获取对应银行名称.
     *
     * @param string $code
     *
     * @return string 银行名称
     */
    public function getCodeBankName($code)
    {
        $temp = $this->bankData;
        foreach ($temp as $k => $v) {
            if ($code == $v['bank_code']) {
                return $v['bank_name'];
            }
        }

        return '';
    }
}
